import os
import platform
import xbmc
import xbmc
import xbmcaddon
import xbmcgui
import xbmcvfs
from xbmcswift2 import Plugin
__addon_id__ = 'service.undermedia.sync'
__addon__ = xbmcaddon.Addon(id=__addon_id__)
__addonversion__ = __addon__.getAddonInfo('version')
__addonname__ = __addon__.getAddonInfo('name')
__addonpath__ = __addon__.getAddonInfo('path').decode('utf-8')
__icon__ = __addon__.getAddonInfo('icon')
__localize__ = __addon__.getLocalizedString

libraries = os.path.join(__addon__.getAddonInfo('Path') , 'lib')
sys.path.append (libraries)
import undermedia


plugin = Plugin(__addonname__, __addon_id__, __file__)

plugin.log.info("Checking Requirements...")
undermedia.checkRequirements()
plugin.log.info("Get Remote Streams and Sync")
undermedia.getMovies()
plugin.log.info("Scanning Library")
undermedia.scanLibrary()
plugin.log.info("Refreshing Container")
xbmc.executebuiltin('Container.Update(' + undermedia.LOCALVIDEOPATH + ')')
xbmc.executebuiltin('UpdateAddonRepos') 